using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PatientDomain;
//using ShivamEMR.Web.Areas.Patient.Models;
using ShivamEMR.Model.DataInterfaces.PatientDataInterf;
using ShivamEMR.Model;

namespace ShivamEMR.Web.Areas.Patient.Controllers
{   
    public class MedicationStatusController : Controller
    {
		private readonly IMedicationStatusRepository medicationstatusRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public MedicationStatusController() //: this(new MedicationStatusRepository())
        {
            this.medicationstatusRepository = Registry.RepositoryFactory.GetMedicationStatusRepository();
        }

        public MedicationStatusController(IMedicationStatusRepository medicationstatusRepository)
        {
			this.medicationstatusRepository = medicationstatusRepository;
        }

        //
        // GET: /MedicationStatus/

        public ViewResult Index()
        {
            return View(medicationstatusRepository.All);//Including(medicationstatus => medicationstatus.Medications));
        }

        //
        // GET: /MedicationStatus/Details/5

        public ViewResult Details(int id)
        {
            return View(medicationstatusRepository.Find(id));
        }

        //
        // GET: /MedicationStatus/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /MedicationStatus/Create

        [HttpPost]
        public ActionResult Create(MedicationStatus medicationstatus)
        {
            if (ModelState.IsValid) {
                medicationstatusRepository.Create(medicationstatus);
                medicationstatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /MedicationStatus/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(medicationstatusRepository.Find(id));
        }

        //
        // POST: /MedicationStatus/Edit/5

        [HttpPost]
        public ActionResult Edit(MedicationStatus medicationstatus)
        {
            if (ModelState.IsValid) {
                medicationstatusRepository.Update(medicationstatus);
                medicationstatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /MedicationStatus/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(medicationstatusRepository.Find(id));
        }

        //
        // POST: /MedicationStatus/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var ms = medicationstatusRepository.Find(id);
            medicationstatusRepository.Delete(ms);
            medicationstatusRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

